package com.example.usermanager.tools;

import com.example.usermanager.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionUtil {
    public static UserInfo getUserBySession(HttpServletRequest request){
        HttpSession session=request.getSession(false);
        if (session!=null&&session.getAttribute(AppFinal.USERINFO_SESSION_KEY)!=null){
            return (UserInfo)session.getAttribute(AppFinal.USERINFO_SESSION_KEY);
        }
        return null;
    }
}
